﻿-- Author      : Zimbu
-- Create Date : 4/20/2008 4:06:50 PM


function DailyTrackerBtnClose_OnClick()
	DailyTrackerFrame:Hide();
end

function DailyTrackerBtnRefresh_OnClick()
	-- for now just use the comm to request our quests
	DailyTrackerComm:SendCategoryRequest("DAILYNORMAL", "DAILYHEROIC", "DAILYFISHING", "DAILYCOOKING");	
end

function DailyTracker:LoadQuest(quest, objQuestName, objLocation)
	objQuestName:SetText( DailyTrackerStrings.Unknown );
	objLocation:SetText( "" );
	
	if quest then
		objQuestName:SetText( quest.Title );
		if quest.Location then
			objLocation:SetText( quest.Location );
		end
	end
end

function DailyTracker:RefreshFrame()
	self:LoadQuest( self:GetCurrentQuest("DAILYNORMAL"), DailyNormal_QuestName, DailyNormal_Location );	
	self:LoadQuest( self:GetCurrentQuest("DAILYHEROIC"), DailyHeroic_QuestName, DailyHeroic_Location );
	self:LoadQuest( self:GetCurrentQuest("DAILYFISHING"), DailyFishing_QuestName, DailyFishing_Location );
	self:LoadQuest( self:GetCurrentQuest("DAILYCOOKING"), DailyCooking_QuestName, DailyCooking_Location );
end

function DailyTrackerFrame_OnLoad()
	-- bind escape to hide the frame
	tinsert(UISpecialFrames,"DailyTrackerFrame");
	
	-- various frames need to be set to localized text
	DailyTrackerTitleString:SetText( DailyTrackerStrings.AddOnTitle .. " " .. DailyTracker.VersionNo );
	
	-- set the category names and default values
	DailyNormal_Category:SetText( DailyTrackerStrings.DailyNormal .. ":" );
	DailyHeroic_Category:SetText( DailyTrackerStrings.DailyHeroic .. ":" );
	DailyFishing_Category:SetText( DailyTrackerStrings.DailyFishing .. ":" );
	DailyCooking_Category:SetText( DailyTrackerStrings.DailyCooking .. ":" );

	DailyTracker:LoadQuest( nil, DailyNormal_QuestName, DailyNormal_Location );	
	DailyTracker:LoadQuest( nil, DailyHeroic_QuestName, DailyHeroic_Location );
	DailyTracker:LoadQuest( nil, DailyFishing_QuestName, DailyFishing_Location );
	DailyTracker:LoadQuest( nil, DailyCooking_QuestName, DailyCooking_Location );
end

function DailyTrackerFrame_OnShow()
	DailyTracker:RefreshFrame();
	PlaySound("igCharacterInfoOpen");
end

function DailyTrackerFrame_OnHide()
	--put your event handler logic here
	PlaySound("igCharacterInfoClose");
end
		
function DailyTrackerFrame_OnUpdate()
end
		